'''
比率翻番的分数PDO
score =A-B*log(odds)
score-PD0=A-B*log(2*odds)
假设我们期望odds=5%时的分值为50分，PDO为10分(即每增加10分odds比例就会缩减一半)，代入式中求得：B=14.43，A=6.78，这个时候odds=10%时score=40
    p=Pd2score()
    b=p.B(10)
    print (b)
    a=p.A(50,0.05,10)
    print (a)
得到score=6.78-14.43*log(odds)违约概率每增加一倍扣10分
'''

import math
class Pd2score:
    def B(self,PD0):
        i=math.log(2)
        return PD0/i
    def A(self,score,odds,PD0):
        i=(PD0*math.log(odds)/math.log(2))
        return score+i
if __name__ == '__main__':
    p=Pd2score()
    b=p.B(10)
    a=p.A(50,0.05,10)
    score=a-b*math.log(0.2)
    print (score)
    